package com.hsxshop.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.hsxshop.service.UserService;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by wangchongya on 17/6/26.
 */
@Controller
@RequestMapping(value = "/user/")
public class UserController {

    @Resource(name = "userService")
    private UserService us;

//    produces="application/json;charset=UTF-8"
    @RequestMapping(value = "list", method = RequestMethod.GET,produces="application/json;charset=UTF-8")
    @ResponseBody
    public String index(){
        String channelId="";
        List list=new ArrayList<Object>();
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("channelId", "123");
        Map<String,Object> map1 = new HashMap<String,Object>();
        map1.put("channelId", "123");
        list.add(map);
        list.add(map1);
        ObjectMapper mapper = new ObjectMapper();
        try {
            channelId = mapper.writeValueAsString(list);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return channelId;
    }

}
